#ifndef MUSICLIST_H
#define MUSICLIST_H

#include <QVector>
#include <QList>
#include <QUrl>
#include <QSet>
#include "music.h"

class MusicList
{
public:
    MusicList();
    //迭代器
    using iterator = QVector<Music>::iterator;
    using const_iterator = QVector<Music>::const_iterator;

    iterator begin() { return musicList.begin(); }
    iterator end() { return musicList.end(); }
    const_iterator cbegin() { return musicList.cbegin(); }
    const_iterator cend() { return musicList.cend(); }

    void addMusicByUrls(QList<QUrl> musicUrls);
    iterator findMusicByMusicId(const QString& musicId);

    //歌曲信息写入数据库
    void writeToDB();

    //从数据库中读取歌曲
    void readFromDB();

private:
    QVector<Music> musicList;

    QSet<QString> musicPaths;   //防止歌曲重复加载
};

#endif // MUSICLIST_H
